angular.module("myApp")
    .controller("MoredataController", ["$scope", "MoredataService", "$state", function($scope, MoredataService, $state) {
        // 点击分类显示/隐藏
        $scope.myVar = true;
        $scope.toggle = function() {
            $scope.myVar = !$scope.myVar;
        };

        // 页面内容默认
        MoredataService.getData("moredata1").success(function(res) {
            $scope.items = res;
        });
        //点击分类,获取数据, 显示
        document.getElementsByClassName("l_flexbox")[0].onclick = function(e) {
            var mdjson = e.target.getAttribute("md");
            // 点击显示相应的数据
            MoredataService.getData(mdjson).success(function(res) {
                $scope.items = res;
            });
            //样式改变
            var n = document.querySelectorAll(".l_flexbox a");
            for (i = 0; i < n.length; i++) {
                n[i].setAttribute("class", "");
            }
            // 添加下划线样式
            e.target.setAttribute("class", "l_active");
        };
    }]);
